<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>一个完成的购物车</title>
  <script src="../vue.js"></script>
</head>
<body>
  <div id="app">
    <h1>产品列表</h1>
    <hr>
    <products @add-to-cart="handleAddToCart"></products>
    <h1>购物车</h1>
    <hr>
    <cart :cart-items="cartItems"></cart>
  </div>
  <script type="module">
    import './products.js'
    import './cart.js'
    new Vue({
      el: '#app',
      data: {
        cartItems: []
      },
      methods: {
        handleAddToCart(cartItems) {
          this.cartItems = cartItems
        }
      },
    })
  </script>
</body>
</html>